package com.hoaptt.pieces;

import com.hoaptt.helper.Coordinate;
import com.hoaptt.model.Board;
import java.util.ArrayList;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



/**
 *
 * @author ThuHoa
 */
public class General extends Piece {

     public General(PLAYER player) {
        super(player);

        this.nameA = Character.toString((char)24101);
        this.nameB = Character.toString((char)23559);
        this.alias = Piece.NAMEPIECE.general;
    }

    @Override
    public ArrayList<Coordinate> generateMove(Board board, Coordinate loc) {
        ArrayList<Coordinate> ar = new ArrayList<Coordinate>();
         int X[] = new int[]{0, 0, 1, -1};
        int Y[] = new int[]{1, -1, 0, 0};
        for (int i = 0; i < X.length; i++) {
            Coordinate coo = new Coordinate(loc.getRow() + X[i], loc.getCol() + Y[i]);
            System.out.println("Coor: " + coo.getRow() + "\t" + coo.getCol());
            // player A, col < = 2, 3<= row <=5
            if (board.getAtLoc(loc).player == Piece.PLAYER.A) {
                //Player A, column <=4 de ko sang song duoc
                if (board.getAtLoc(coo) != null && coo.getCol() <= 2 && coo.getRow()>=3 && coo.getRow()<=5) {
                    ar.add(coo);
                }
            }
            if (board.getAtLoc(loc).player == Piece.PLAYER.B) {
                //Player A, column <=4 de ko sang song duoc
                if (board.getAtLoc(coo) != null && coo.getCol() >= 7 && coo.getRow()>=3 && coo.getRow()<=5) {
                    ar.add(coo);
                }
            }
        }
          return ar;
    }

}
